package fangzhiyi.work.auto;

/**
 * @author fangzhiyi
 * @version 1.0
 * @date 2025/3/20 17:26
 * @description 汽车类
 */
public class Auto {
    //成员变量
    public int tire;
    public String color;
    public double weight;
    public double speed;
    //构造方法
    public Auto(int tire, String color, double weight, double speed) {
        this.tire = tire;
        this.color = color;
        this.weight = weight;
        this.speed = speed;
    }
    //加速
    public void addSpeed(double autoSpeed){
        this.speed = this.speed+autoSpeed;
        System.out.println("汽车加速,当前速度为："+this.speed+"km/h");
    }
    //减速
    public void minusSpeed(double autoSpeed){
         this.speed = this.speed-autoSpeed;
         if (this.speed>0){
             System.out.println("汽车减速,当前速度为："+this.speed+"km/h");
         }else {
             this.speed=0;
             System.out.println("汽车");
         }
    }
    //停车
    public void stop(){
        this.speed = 0;
        System.out.println("汽车停车");
    }
}
